package cn.consult.controller.sys.enterprise;

import cn.consult.common.api.CommonPage;
import cn.consult.common.api.CommonResult;
import cn.consult.sys.entity.TDwellEmployee;
import cn.consult.sys.entity.TEnterprise;
import cn.consult.sys.service.TEnterpriseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "企业管理 > 企业信息")
@RestController
@RequestMapping("/enterprise/enterpriseXx")
public class TEnterpriseXxController {

    @Autowired
    TEnterpriseService tEnterpriseService;

    @ApiOperation("getEnterpriseAll =>  条件查询企业信息")
    @GetMapping("/getEnterpriseAll")
    public CommonResult getEmployeeAll(@RequestParam Map<String, Object> params) {
        IPage<TEnterprise> page = tEnterpriseService.getEmployeeAll(params);
        return CommonResult.success(CommonPage.restPage(page));
    }

    @ApiOperation("getAll =>  查询所有信息")
    @GetMapping("/getAll")
    public CommonResult getAll() {
        List<TEnterprise> list = tEnterpriseService.list();
        return CommonResult.success(list);
    }

    @ApiOperation("addEnterprise =>  添加企业信息")
    @PostMapping("/addEnterprise")
    public CommonResult addEnterprise(@RequestBody TEnterprise tEnterprise) {
        boolean flag = tEnterpriseService.saveEnterprise(tEnterprise);
        return CommonResult.success(flag);
    }
    @ApiOperation("updateEnterprise =>  修改企业信息")
    @PutMapping("/updateEnterprise")
    public CommonResult updateEnterprise(@RequestBody TEnterprise tEnterprise) {
        boolean flag = tEnterpriseService.updateEnterprise(tEnterprise);
        return CommonResult.success(flag);
    }

    @ApiOperation("delEnterprise =>  删除企业信息")
    @DeleteMapping("/delEnterprise/{id}")
    public CommonResult delEnterprise(@PathVariable Long id) {
        boolean b = tEnterpriseService.removeById(id);
        return CommonResult.success(b);
    }

    @ApiOperation("getEnterpriseById =>  根据id查询企业信息")
    @GetMapping("/getEnterpriseById/{id}")
    public CommonResult getEmployeeById(@PathVariable Long id) {
        TEnterprise byId = tEnterpriseService.getById(id);
        return CommonResult.success(byId);
    }


}
